test(ts-plugin): split remaining e2e tests into per-behavior cases#382
Conversation
…ntax / pure-css-file / ignore-generated-files e2e tests into per-behavior cases Each test now owns a minimal fixture and asserts a single behavior, completing the multi-PR series started in #378. Hard-coded line/offset literals are replaced with getRange / getLoc, and the inline diagnostic snapshot in ignore-generated-files is replaced with a structural toStrictEqual. Also adds a missing case to refactor.test.ts: the Create CSS Module file refactor is suppressed when the paired *.module.css already exists. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…d.ts exclusion behavior The previous name described the observable diagnostic; the new name foregrounds the actual invariant under test: ts-plugin removes generated .d.ts files from the module resolution path even when their directory is listed in rootDirs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
There was a problem hiding this comment.
Pull request overview
This PR completes the ongoing ts-plugin e2e test refactor series by restructuring the remaining e2e tests so each test owns a minimal fixture and asserts a single behavior. This aligns these files with the newer setupFixture + builder utilities introduced earlier in the series and improves readability and maintainability of the e2e suite.
Changes:
- Refactors multiple e2e test files to create per-test minimal fixtures via
setupFixture, and (where relevant) parameterizes coverage withdescribe.eachfornamedExports. - Improves assertion clarity by replacing inline snapshots with
toStrictEqualand by computing locations/ranges viagetLoc/getRange. - Adds/clarifies a few missing/negative behavior cases (notably around refactor suppression when the paired CSS module already exists).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ts-plugin/e2e-test/regression/pure-css-file.test.ts | Switches to setupFixture and simplifies diagnostics assertions for non-module .css files. |
| packages/ts-plugin/e2e-test/invalid-syntax.test.ts | Splits invalid CSS syntax coverage into focused tests and runs them for both namedExports variants. |
| packages/ts-plugin/e2e-test/ignore-generated-files.test.ts | Replaces diagnostic snapshot with explicit toStrictEqual using computed ranges; clarifies test intent around rootDirs. |
| packages/ts-plugin/e2e-test/feature/rename-file.test.ts | Splits rename-file behavior into separate tests (TS import, CSS @import, CSS @value ... from) and runs for both namedExports variants. |
| packages/ts-plugin/e2e-test/feature/refactor.test.ts | Splits refactor coverage into separate tests for “applicable refactors” vs “edits for refactor”, adding the “paired module exists” suppression case. |
| packages/ts-plugin/e2e-test/disabled.test.ts | Renames/reframes the disabled-path test and uses setupFixture + getLoc for precise positioning. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Refactor the remaining e2e test files so that each
testblock owns a minimal fixture and asserts a single behavior, completing the multi-PR series started in #378.This is the final PR of the series (see #378 / #379 / #380 for the per-feature PRs).
What's new
packages/ts-plugin/e2e-test/feature/refactor.test.ts: split into 4 behavior-focused tests; added a missing case for "refactor is suppressed when the paired CSS module already exists".packages/ts-plugin/e2e-test/feature/rename-file.test.ts: split into 3 behaviors × 2namedExportsvariants = 6 tests, organized by which import syntax gets rewritten.packages/ts-plugin/e2e-test/disabled.test.ts: kept as 1 test; renamed for specificity and switched tosetupFixture/getLoc.packages/ts-plugin/e2e-test/invalid-syntax.test.ts: split the shared fixture into 2 behavior-focused tests × 2 variants = 4 tests.packages/ts-plugin/e2e-test/regression/pure-css-file.test.ts: kept as 1 test; switched tosetupFixturefor consistency.packages/ts-plugin/e2e-test/ignore-generated-files.test.ts: kept as 1 test; replaced the inline diagnostic snapshot withtoStrictEqual+ dynamically computed ranges. Renamed the test to focus on the actual invariant ("excludes generated .d.ts files from module resolution even when listed in rootDirs") rather than the observable diagnostic.Note on
describe.eachfornamedExportsThe runbook (#378) recommends wrapping every test in
describe.eachfornamedExports. Several files in this PR (refactor,disabled,regression/pure-css-file,ignore-generated-files) skip the wrap because the behaviors under test do not pass through the .d.ts / Volar.js mapping pipeline:refactoronly inspects file namesdisabledshort-circuits the entire pluginpure-css-filecovers files ts-plugin does not process at allignore-generated-filesexercises file resolution, independent of import shapeWrapping these would double the test count without exercising additional code paths.
Test plan
vp test --project e2e packages/ts-plugin/e2e-test/feature/refactor.test.ts— 4 passedvp test --project e2e packages/ts-plugin/e2e-test/feature/rename-file.test.ts— 6 passedvp test --project e2e packages/ts-plugin/e2e-test/disabled.test.ts— 1 passedvp test --project e2e packages/ts-plugin/e2e-test/invalid-syntax.test.ts— 4 passedvp test --project e2e packages/ts-plugin/e2e-test/regression/pure-css-file.test.ts— 1 passedvp test --project e2e packages/ts-plugin/e2e-test/ignore-generated-files.test.ts— 1 passedvp test --project e2e(full e2e suite) — 127 passed (1 todo)vp check(format + lint + type) — pass🤖 Generated with Claude Code